﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using keithfletcher.org;

namespace Gxc2CsBrute
{
   [Application(
    HelpOptions = new string[] { "?", "help" },
    OptionPrefixes = new char[] { '/', '-' },
    ThrowParsingExceptions = false)]
   [Option("symbols",
       ShortDescription = "Symbol file path",
       LongDescription = "The file with variables used in GXC",
       ValuePresence = OptionAttributeValuePresence.MustHaveValue,
       IsOptional = false)]
   [Option("code",
      ShortDescription = "Code file path",
      LongDescription = "The file with non interactive GXC code.",
      ValuePresence = OptionAttributeValuePresence.MustHaveValue,
      IsOptional = false)]
   [Option("cs",
     ShortDescription = "Output CS file",
     LongDescription = "The output CSharp file.",
     ValuePresence = OptionAttributeValuePresence.MustHaveValue,
     IsOptional = false)]

   class Program : CommandLineBase
   {
      static void Main(string[] args) { new Program(args); }

      private Program(string[] args)
         : base(args)
      {
         if (ParseErrors)
         {
            base.WriteLine("Errors occurred!");
            return;
         }

         if ((Options.Count == 0) &&
             !base.ShowingHelp)
            ShowHelp();

         if (!ShowingHelp)
         {
            gxc2csharp.Translator.GxcParser parser = new gxc2csharp.Translator.GxcParser();
            parser.ParseSymbolFile(Options["symbols"].Value);
            parser.ReadExecuteMethodFile(Options["code"].Value);
            parser.WriteCSCode(Options["cs"].Value);
         }
      }        
   }
}
